public class DijkstraAndFloyd {
    public static void main(String[] args){
        int max = 7;
        int map[][] = {{' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G'},
                {'A', -1, 4, 6, 6, -1, -1, -1},
                {'B', -1, -1, 1, -1, 7, -1, -1},
                {'C', -1, -1, -1, -1, 6, 4, -1},
                {'D', -1, -1, 2, -1,-1, 5, -1},
                {'E', -1, -1, -1, -1, -1, -1, 6},
                {'F', -1,-1,-1,-1,1,-1,8},
                {'G', -1, -1, -1, -1, -1, -1, -1}};
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map.length; j++) {
                if (i == 0 || j == 0) {
                    System.out.printf("%-4c", map[i][j]);
                } else {
                    System.out.printf("%-4d", map[i][j]);
                }
            }
            System.out.println();
        }
        int distance[]=new int[max+1];
        int direction[]=new int[max+1];
        int object[]=new int[max+1];
        for(int i=0;i<max+1;i++){
            direction[i]=-1;
            object[i]=0;
            distance[i]=10000;
        }
        Setting.dijkstra(object,direction,distance,map,'A');
        System.out.println();


        String node[] = {" ", "A","B","C","D","E","F","G"};
        int map02[][]=map;
        String path[][]=new String[max+1][max+1];
        for(int i=1;i< path.length;i++){
            for(int j=1;j< path.length;j++){
                if(map02[i][j]!=-1){
                    path[i][j]="=>"+node[i]+node[j];
                }else if(map02[i][j]==-1){
                    map02[i][j]=1000;
                }
            }
        }
        Setting.floyd(map02,path);
        System.out.println(path[1][7]);
    }
}
